package javafoundation.notes;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Random;

import static java.lang.System.*;

/**
 * @ClassName Double和科学计数法
 * @Description Double和科学计数法
 * @Author dzf
 * @Date 2022/7/11 17:11
 * @Version 1.0
 */
public class Double和科学计数法 {

    public static void main(String[] args) {
        String str = "45,000.00";
        Double of = Double.valueOf(str.replace(",", ""));
        //Double类型格式化
        DecimalFormat format = new DecimalFormat("#.00");
        out.println(format.format(of));


        Random random = new Random();
        int i = random.nextInt(99);
        out.println(i+1);
        String.format("%02d",i);
        out.println(i+1);


        //科学计数法转Double
        String s = "2.366544545665356556E12";
        BigDecimal decimal = new BigDecimal(Double.valueOf(s));
        out.println(decimal.toString());

        String s1 = NumberFormat.getNumberInstance().format(Double.valueOf(s));
        out.println(s1);

    }
}
